package com.tac.common.utils;

import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

public class ImgUtils {


    public static String getImgName(String baseUrl, MultipartFile file) throws IOException {
        String originalFilename = file.getOriginalFilename();
        String substring = originalFilename.substring(originalFilename.lastIndexOf("."));
        String replace = UUID.randomUUID().toString().replace("-", "");
        String imgName=replace+substring;

        file.transferTo(new File(baseUrl+imgName));
        return "profile/"+imgName;
    }
}
